home *** CD-ROM | disk | FTP | other *** search
- // MAIN MODULE
-
-
-
-
- // CURRENT BUG: nearly done now!
- // swarm thinks it has killed you when it hasn't.
-
- // whatmonster 0xff = wiz, whatside 0xff = nothing there
- #include <dos.h>
- #include<process.h>
- #include <graphics.h>
- #include <string.h>
- #include <conio.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
-
- #include "ar256h.cpp"
- #include "ar256def.h"
- enum tf {true,false};
-
- #include "svga256.h"
- #define MONSTERS 27
-
- char cheetR=73; //set to # of player who will be helped...
- char players,width,height,maxmon;
- int thisturn=0;
- int strength_history[4][50];
- int tree_history[4][50];
- int attack_history[5][50];//1 for mirkwoods
- int luck_history[5]; // 1 for mirkwoods
- //char equal_flag;
- unsigned char curpla,curmon,done=0,moves,noisy=0,isalive[4];
-
- unsigned char pcol[4]={6,12,24,19};
- char pname[4][9];
- char pstartx[4];
- char pstarty[4];
- char pgraph[4];
- char moncounter[4]={0};
- char kills[4]={0};
- char balls=1;
- signed int alignment[4]={0};
- char pattern[8]={0x33,0xcc,0x33,0xcc,0x33,0xcc,0x33,0xcc};
- char spellprob[59]={
- 9,3,7,1,2,2,4,2,3,2,//0-9
- 2,5,3,5,3,5,3,2,3,5,//10-19
- 5,4,6,3,5,3,3,3,3,3,//20-29
- 6,2,2,2,2,2,2,3,2,2,//30-39
- 2,5,4,4,7,2,2,2,2,2,//40-49
- 5,3,3,3,2,2,2,2,3}; //50-59
- int UD_MONSTERS=0;
- int NOT_REGD=0; //this is set to 1 if it cant find stats.dat
- int SLIDE=1; //set to 0 if noslide.
- unsigned char curx=30,cury=30;
- square sq[30][30];
- createitall(char);
- tweenturns();
- drawmap(char,char);
- char cursor=0;
- ending();
- endingtwo();
- drawtile(char,char,char,char);
- drawjustland(char,char,char,char);
-
- readingfx();
- //readinrest();
- monster mondata[28]; //monster objects being used to store data
- monster mon[4][30];
- monster create(char,char,unsigned char,char,char,char);
- //recce();
- fire(char,char);
- showfire(int,int,int,int,int);
- char fight(monster,monster);
- spells(void);
- sento(unsigned char,unsigned char);
- flyto();
-
-
- castspell(int,int); //if 2nd arg then illusion
- void select(char *,char *,int);
- void getname(int,int,int);
- void getadj(char *,char *);
- decide(int,int);
- void foom(int,int); //show a shroom at map (int,int). calls drawtile.
- void moof(int,int); //show a pentagram. calls nowt.
- void penty(int size,int delay); //shows a penty twice. use moveto() first
- void boof(int,int); //circles around int,int
- void swarm(int,int,int,int,int); //covers an area in dots :I
- void crawler(int,int,int,int); //line of fooms
- // graphics data
- unsigned char *terrt[8];
- unsigned char *shroom[8]; //globble pointers to gfx yo mofo
-
- unsigned char *tile[26];
- unsigned char *ball[6];
- unsigned char *start;
- unsigned char *sparks;
-
-
- int range(long,long,long,long);
- int linesight(int,int,int,int);
- int rangesight(int,int,int,int,int);
- int check(int,int);
- int adjust(char *,char *);
-
- int frontend(int);
- void besilly(int);
- void memerror();
- void title();
- int cycleballs();
- char mygetch();
- //void besillier(void);
-
- int bigtile(int,int,unsigned char far *,char,char); //ptr is to 0x400 array
-
- /*void bip(int);
- void risingbip(int);
- void downbip(int);
- void lowbip(int);
- void tripbip(int);
-
- mark(int,int);
- niceellipse(int,int,int,int);*/
- void usemouse();
- void memerror(); // 4 little text msgs.
- void nospells();
- void noshots();
- void orbattacked(int,int);
- int drawsparks(int,int);
- //void norange();
-
- //char *disc;
-
- extern void bip(int);
- extern void lowbip(int);
- extern void tripbip(int);
- extern void downbip(int);
- extern void risingbip(int);
- extern void besilly(int);
- //#include "ar256sp.cpp"
- #include "ar256m.cpp"
- mouse m;
-
- #include "ar256h3.cpp" //the function 'create' which contains data
-
-
- screenmsgs s;
-
- extern int tweenturns();
- extern int frontend(int);
- extern void getname(int,int,int);
- extern int mark(int,int);
- extern int niceellipse(int,int,int,int);
- extern int bigtile(int,int,unsigned char far *,char,char);
- extern int ending();
- extern int ending2();
- extern int bossmsg();
- extern void getstrengths();
-
- extern int drawjustland(char,char,char,char);
- extern int spritepath(int,int,int,int,unsigned char *);
- //extern int drawjustframe(int,int,unsigned char *);
- //extern int DetectVGA256();
- //extern void dimthegreys();
-
- //#include "ar256h5.cpp" //frontend and tweenturns
-
-
- main(int argc,char *argv[])
-
- {
- //besilly(0);
- unsigned char shots,spelt,c;int i,j;char test[5];
-
- clrscr();
- randomize();
-
- title();
-
-
-
-
-
- strcpy(pname[0],"Cherry");
- strcpy(pname[1],"Iskander");
- strcpy(pname[2],"Crowley");
- strcpy(pname[3],"Virgil");
-
- j=0;
-
-
- for(i=1;i<argc;++i)
- {
- if(argv[i][0]=='-')
- {
- if(!strcmp(argv[i],"-nocentre"))m.initbitmap(1);else m.initbitmap(0);
- if(!strcmp(argv[i],"-noslide"))SLIDE=0;
- }
- else
- {
-
- strcpy(pname[j],argv[i]);
- if(!strcmp(argv[i],"*Ben*"))cheetR=j;
- ++j;
- }
- }
-
-
- m.unsetbounds();
-
-
-
-
- readingfx();
-
-
-
-
-
- createitall(frontend(j)); //frontend returns 1 for equal spells
-
-
-
- s.logo();
- s.boxes();
-
-
-
- for(;;){
-
- // MAIN LOOP!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- for (curpla=0;curpla<players;++curpla)
- {
-
- if (isalive[curpla])
- {
-
- s.boxes();
- s.plecho(curpla);
-
- for (curmon=0;curmon<maxmon;++curmon)
- {
-
- if ((mon[curpla][curmon].status)&&(mon[curpla][curmon].status<4))
- {
- //if monster moveable, look at monster and set move counter
-
- curx=mon[curpla][curmon].x;cury=mon[curpla][curmon].y;
- drawmap(curx,cury);m.putat(240,240);
- s.mecho(curpla,curmon);
- moves=mon[curpla][curmon].mmoves;
- s.modecho(1);
- s.plecho(curpla);
- shots=mon[curpla][curmon].mshots;
- spelt=0;
-
- while(moves)
- {
- //-------recce bit breaks on keypress but leaves keypress alone
- i=1;//if (i==1) then curx=current monster x
- cursor=0;
-
- s.modecho(1);
-
- for(;;)
- {
- cursor=0;
- while(m.wheremouse())
- {
- //m.adjustmouse(curx,cury);
- cycleballs();
-
-
-
- if(kbhit())
- {
- if(i==0)
- {
- curx=mon[curpla][curmon].x,cury=mon[curpla][curmon].y;
- drawmap(curx,cury);m.putat(240,240);
- i=1;getch();
- }
- else
- {
-
- break;//if already centered pass keypress along...
- }
- }
- }
- if(kbhit())break;
- i=0;
- curx=curx+(m.x/32)-7;cury=cury+(m.y/32)-7;
- drawmap(curx,cury);m.putat(240,240);
- s.recho(curx,cury);
-
- }
- //---------end of recce bit
- c=getch();
- switch(c)
- {
-
- case'8':{sento(curx,cury-1); break;}
- case'7':{sento(curx-1,cury-1);break;}
- case'2':{sento(curx,cury+1); break;}
- case'9':{sento(curx+1,cury-1);break;}
- case'4':{sento(curx-1,cury); break;}
- case'1':{sento(curx-1,cury+1);break;}
- case'6':{sento(curx+1,cury); break;}
- case'3':{sento(curx+1,cury+1);break;}
-
-
-
- case'f':if(shots){s.modecho(4);shots=fire(shots,mon[curpla][curmon].fire);cursor=0;s.modecho(1);break;}
- else{noshots();break;}
- case's':if((mon[curpla][curmon].spellnum)&&(!spelt))
- {
-
- spells();
- s.plecho(curpla);s.modecho(1);s.mecho(curpla,curmon);
- ++spelt;
- break;
- }
- else{nospells();break;}
-
- case' ':{bip(5);break;}
- case'Q': // quit. this outer be a function
- {
- moof(curx,cury);setfillstyle(1,0);bar(0,0,640,480);settextstyle(0,0,1);
- outtextxy(240,190,"You agree to differ.");
- getch();closegraph();
- clrscr();m.unsetbounds();besilly(1);break;
- }
- case't':if(mon[curpla][curmon].fly)
- {flyto();m.bitmapoff();m.bitmapon(0,pcol[curpla]);cursor=0;break;}
- else{break;}
-
- case'!':
- {
- closegraph();clrscr();bossmsg();m.unsetbounds();exit(0);
- break;
- }
- case'?':
- {
- s.help();drawmap(curx,cury);
- break;
- }
-
- default:
- //s.bargraph(luck_history,"rolled his dice;","General luckiness of players:");
-
- break;
-
- }//end of switch
- if(c==' ')break; //go on to next monster
- }//end of while
-
-
- s.modecho(3);lowbip(1);
- if(mygetch()=='!'){closegraph();bossmsg();exit(0);};
- s.boxes(); //this getch might take the char from case '!'
-
- }// if monster is alive if
-
-
- }// monster loop
- s.modecho(5);downbip(3);if(mygetch()=='!'){closegraph();bossmsg();exit(0);}
- s.boxes();s.usespace();
- }//if player is alive if
- }// player loop
- tweenturns();s.boxes();
- }// for(;;)
-
-
-
- return(0);
- }
-
-
-
-
-
-
- createitall(char equal_flag)
- {
-
-
- int i,j,x,y,treex,treey,r,k;
-
- int given=1; char equalspells[28];
-
-
- for (i=0;i<width;++i) // set whatside to blanks
- {
- for (j=0;j<height;++j)
- {
- sq[i][j].whatside=0xff;sq[i][j].whose=0xff;
- }
- }
-
- for(i=0;i<10;++i)
- {
- x=random(width),y=random(height);
- sq[x][y].land=5;sq[x][y].whose=0xff; //place trees and mwoods
- }
- for(i=0;i<5;++i)
- {
- x=random(width),y=random(height);
- sq[x][y].land=6;sq[x][y].whose=0xff;
- }
- i=0;
-
-
- while(given<25)
- {
- r=random(59);
- if(random(8)+1>spellprob[r])
- {
- equalspells[given]=r; //make table of spells
- ++given;
- }
- }
-
-
-
- for (i=0;i<players;++i)
- {
- create(i,0,0xff,1,pstartx[i],pstarty[i]);
-
- //strength_history[i][0]=mon[i][0].power();
-
- if(equal_flag)
- {
- for(k=1;k<25;++k) //insert spells from table
- {
- mon[i][0].spells[k]=equalspells[k];
- }
- }
- //make clumps of trees either in middl or at orbs
- treex=pstartx[i];treey=pstarty[i];
- if(random(3)){treex=width/2+random(7)-3;treey=height/2+random(7)-3;}
- moncounter[i]=1;
- for (j=0;j<15;++j)
- {
- x=random(10)-5,y=random(10)-5;
- if((range(0,0,x,y)<6)&&
- (x+treex>0)&&(y+treey>0)&&(x+treex<width)&&(y+treey<height)&&
- (sq[x+treex][y+treey].land<10))
- {
- sq[x+treex][y+treey].land=1;
- sq[x+treex][y+treey].whose=i;
-
-
- }
-
- }
- if(balls){
- sq[pstartx[i]][pstarty[i]].land=10;
- sq[pstartx[i]-1][pstarty[i]].land=11;
- sq[pstartx[i]+1][pstarty[i]].land=12;
- sq[pstartx[i]][pstarty[i]+1].land=13;
- sq[pstartx[i]-1][pstarty[i]+1].land=14;
- sq[pstartx[i]+1][pstarty[i]+1].land=15;
- sq[pstartx[i]][pstarty[i]].whose=i;
- sq[pstartx[i]-1][pstarty[i]].whose=i;
- sq[pstartx[i]+1][pstarty[i]].whose=i;
- sq[pstartx[i]][pstarty[i]+1].whose=i;
- sq[pstartx[i]-1][pstarty[i]+1].whose=i;
- sq[pstartx[i]+1][pstarty[i]+1].whose=i;}
-
- }
-
-
-
-
-
- getstrengths();
- for(i=0;i<players;++i)
- {
- attack_history[i][0]=0;
- }
-
- return (0);
-
-
-
-
- }
-
-
- drawmap(char centrex,char centrey)
- {
- int i,j,recx,recy;
-
- m.bitmapoff();
- for (i=0;i<15;++i)
- {
- for (j=0;j<15;++j)
- {
- //cur_tile_col=117+(i+j)/5;
- drawtile(centrex-7+i,centrey-7+j,centrex,centrey);
-
- }
-
- }
- setcolor(0x0f);
- rectangle(32*7-1,32*7-1,32*8+1,32*8+1);//-1 looks a bit better...
- rectangle(0,0,32*15,479);
-
- recx=((width-centrex)+7)*32;
- recy=((height-centrey)+7)*32;
-
- if(recx>480)recx=480;
-
-
- rectangle((7-centrex)*32,(7-centrey)*32,recx,recy);
- m.setbounds(centrex,centrey);
- //m.putat(240,240);
- m.bitmapon(cursor,pcol[curpla]);
-
- return(0);
-
-
- }
-
-
-
-
-
-
-
- drawtile (char tilex,char tiley, char centrex,char centrey)
- {
- int i,nx,ny,px,py;char mtile; //nx,ny are toplefts pix
-
- nx=((signed char)tilex-centrex+7)*32;ny=((signed char)tiley-centrey+7)*32;
-
- if((tilex>=width)||(tiley>=height)||(tilex<0)||(tiley<0))//if off map dont draw. You'd think it'd wrap and be always false but it DOESNT.
- {
- setfillstyle(1,0xd3);
- bar(nx,ny,nx+31,ny+31);
- return(1);
- }
- setfillstyle(1,2);
-
- bar(nx,ny,nx+31,ny+31);
-
- if(sq[tilex][tiley].land)
- {
- if((sq[tilex][tiley].land==10)&&(sq[tilex][tiley].whatside!=0xff))
- {
- for (i=0;i<0x400;++i) //draw ball+wiz
- {
- px=nx+(i % 32);py=ny+(i / 32);
- if (start[i] != 0xff) putpixel(px,py,start[i]);
- if (start[i] == 0xfe) putpixel(px,py,pcol[sq[tilex][tiley].whatside]);
- if (start[i] == 247) putpixel(px,py,247+sq[tilex][tiley].whose);
- }
- return(0);
- }
-
- if(sq[tilex][tiley].land>9)
- {
- for (i=0;i<0x400;++i) //draw ballz
- {
- px=nx+(i % 32);py=ny+(i / 32);
- if (ball[sq[tilex][tiley].land-10][i] != 0xff) putpixel(px,py,ball[sq[tilex][tiley].land-10][i]);
- if (ball[sq[tilex][tiley].land-10][i] == 247) putpixel(px,py,247+sq[tilex][tiley].whose);
- }
-
- }
-
- else
- {
- for (i=0;i<0x400;++i) //draw trees craters etc etc
- {
- px=nx+(i % 32);py=ny+(i / 32);
- if (terrt[sq[tilex][tiley].land-1][i] != 0xff) putpixel(px,py,terrt[sq[tilex][tiley].land-1][i]);
- }
- }
- }
-
-
-
- if (sq[tilex][tiley].whatside!=0xff)
- {
- if (!(sq[tilex][tiley].whatside % 2))//if even player
- {
-
- mtile=mon[sq[tilex][tiley].whatside][sq[tilex][tiley].whatmonster].graphic;
- if (mon[sq[tilex][tiley].whatside][sq[tilex][tiley].whatmonster].status==0x11)
- {
- for (i=0;i<0x400;++i) //if corpse
- {
- px=nx+(i % 32);py=ny+(i / 32);
- if (!tile[mtile][i])putpixel(px,py,0x07);//print grey outline
-
- }
- return(0);
- }
- for (i=0;i<0x400;++i) //if alive
- {
- px=nx+(i % 32);py=ny+(i / 32);
- if (tile[mtile][i]<254) putpixel(px,py,tile[mtile][i]);
- if (tile[mtile][i] == 254)putpixel(px,py,pcol[sq[tilex][tiley].whatside]);//print col of player
- }
- }
- else
- { //if even player face left
- mtile=mon[sq[tilex][tiley].whatside][sq[tilex][tiley].whatmonster].graphic;
- if (mon[sq[tilex][tiley].whatside][sq[tilex][tiley].whatmonster].status==0x11)
- {
- for (i=0;i<0x400;++i) //if corpse
- {
- px=nx+(32-(i % 32));py=ny+(i / 32);
- if (!tile[mtile][i])putpixel(px,py,0x07);//print grey outline
-
- }
- return(0);
- }
- for (i=0;i<0x400;++i)
- {
- px=nx+(32-(i % 32));py=ny+(i / 32);
- if (tile[mtile][i]<254) putpixel(px,py,tile[mtile][i]);
- if (tile[mtile][i] == 254)putpixel(px,py,pcol[sq[tilex][tiley].whatside]);//print col of player
- }
- }
-
-
- }
-
-
- return (0);
- }
-
-
- //FIGHT FNCTN FIGHT DOESNT CALL A DAMN THING EXCEPT FOR MSGS ------------
-
- char fight(monster attacker,monster defender)
- {
- char out,i;
-
- if (sq[defender.x][defender.y].land==10)defender.defend+=26;
-
- //if (sq[defender.x][defender.y].land==0x0f)defender.defend+=6;
- if (defender.status==0x11) //if a corpse is attacked
- {s.fecho(attacker,defender,2);moves=0;lowbip(4);return(0x11);}
-
-
- if (
- ((attacker.status!=3)&&(attacker.id<0x80))//if attacker neither undead nor illusory undead
- &&((defender.status==3)||((defender.id>=0x80)&&(defender.id!=0xff)))
- )
- //if defender real or illusory undead
- {s.fecho(attacker,defender,3);moves=0;lowbip(4);return(3);}
-
- if (decide(attacker.attack,defender.defend))
- {
- s.fecho(attacker,defender,0);
- risingbip(5);
- if (defender.status==1){out=0x11;} // live -> corpse
- if ((defender.status==3)||(defender.status==2))
- {
- out=0x00; // illusion/undead -> nonexist
- //sq[defender.x][defender.y].whatside=0xff;
- //sq[defender.x][defender.y].whatmonster=0;
-
- }
- ++kills[curpla];
- }//attacker wins
- else
- {
- s.fecho(attacker,defender,1);
- lowbip(2);
- out=defender.status;
- }//defender wins
- if(sq[defender.x][defender.y].land==10)
- {
- orbattacked(defender.x,defender.y);
- }
- else
- {
- for(i=0;i<10;++i)
- {
- mon[sq[defender.x][defender.y].whatside][sq[defender.x][defender.y].whatmonster].status
- =0x11;drawtile(defender.x,defender.y,curx,cury);delay(i*15);
- mon[sq[defender.x][defender.y].whatside][sq[defender.x][defender.y].whatmonster].status
- =1;drawtile(defender.x,defender.y,curx,cury);delay(i*15);
- }
- }
- moves=0;
-
- return(out);
- }
-
- void orbattacked(int ox,int oy) // little effect for attack on orb
- {
- int i;
- drawsparks(ox,oy);
- for(i=0;i<10;++i)
- {
-
- setrgbpalette(247+sq[ox][oy].whose,0,0,0);
- delay(10);
- setrgbpalette(247+sq[ox][oy].whose,random(120),random(120),0);
- delay(15);
- }
- drawtile(ox,oy,curx,cury);
- cycleballs();
- }
-
-
-
- drawsparks(int x,int y) //used by orbattacked only
- {
- int i,px,py;
- for(i=0;i<0x400;++i)
- {
- px=(x-curx+7)*32+(i%32);py=(y-cury+7)*32+(i/32);
- if(sparks[i]!=255)putpixel(px,py,sparks[i]);
- }
- }
-
-
- // MOVEMENT FNCTN SENTO MAY CALL FIGHT ---------------------------
- //check for enemy trees first.
- sento(unsigned char newx, unsigned char newy)
- {
-
- if(adjust(&newx,&newy)){lowbip(3);--moves;return(0);}
- //if(mon[curpla][curmon].fly){flyto(newx,newy);return(0);}
-
- if((sq[newx][newy].land>6)&&(sq[newx][newy].land<10))return(0);
- //dont bother if fire.
-
- if(sq[newx][newy].land==10)//if tries to enter ball
- {
-
- if((curmon==0)&&(sq[newx][newy].whose==curpla))
- {
- moves=0;
- sq[curx][cury].whatside=0xff;
- sq[newx][newy].whatside=curpla; //if wiz & his ball enter it
- sq[newx][newy].whatmonster=curmon;
- mon[curpla][curmon].x=newx;
- mon[curpla][curmon].y=newy;
- cury=newy;curx=newx;
- drawmap(newx,newy);
- return(0);
- }
- else
- {
- if(sq[newx][newy].whose==curpla)return(0); //if your own ball no nowt
- if(sq[newx][newy].whatside==0xff)
- {
- if(random(6))
- {
- risingbip(7);
- sq[newx][newy].whose=curpla;
- }
- // 1/6 chance of subverting ball if unoccupied
-
- return(0);
- }//if enemy ball but no monster inside it
- //otherwise fight thing will be used later on in this fnctn... i hope
-
- }
-
- }
-
-
- if((sq[newx][newy].land==1)&&sq[newx][newy].whose!=curpla)
- { //if enemy tree.
- if(decide(mon[curpla][curmon].attack,1))
- {
- s.trecho(mon[curpla][curmon],1); risingbip(3);// kill tree msg
- sq[newx][newy].land=3;sq[newx][newy].whose=4;moves=0;
- }
- else
- { //failed attack on tree.
- s.trecho(mon[curpla][curmon],0);moves=0;lowbip(2);
- }
-
- return(0); // no point checking for move/fight if there was a tree
- }
- if(sq[newx][newy].land==5)
- { //if mirkwood
- if(decide(mon[curpla][curmon].attack,2))
- {
- s.trecho(mon[curpla][curmon],1);
- sq[newx][newy].land=0;moves=0;risingbip(3);
- }
- else
- {
- s.trecho(mon[curpla][curmon],0);moves=0;lowbip(2);
- }
- return(0);
- }
- if((sq[newx][newy].whatside!=0xff)&&(sq[newx][newy].whatside!=curpla))
- { //if owned by enemy
- mon[sq[newx][newy].whatside][sq[newx][newy].whatmonster].status=
- fight(mon[curpla][curmon],mon[sq[newx][newy].whatside][sq[newx][newy].whatmonster]);
- if(mon[sq[newx][newy].whatside][sq[newx][newy].whatmonster].status==0)
- {sq[newx][newy].whatmonster=0;sq[newx][newy].whatside=0xff;}
- //if a monster vanished in fight, adjust it's square.
- drawmap(curx,cury);
- // sets defender status to value of fight
- }
-
- else{
- if((sq[newx][newy].land!=2)&&(sq[newx][newy].whatside!=curpla))
- { // ie if no wall and no other monster in way
- if(sq[newx][newy].land==6)
- { // if grass
- if (moves>1)
- {--moves;}
- else
- {return(0);}
- }
-
- drawjustland(curx,cury,curx,cury);
- spritepath(32*7,32*7,(-curx+newx+7)*32,(-cury+newy+7)*32,tile[mon[curpla][curmon].graphic]);
-
-
- mon[curpla][curmon].y=newy;
- mon[curpla][curmon].x=newx;
- sq[curx][cury].whatmonster=0;sq[curx][cury].whatside=0xff;
- cury=newy;curx=newx;
- sq[curx][cury].whatmonster=curmon;sq[curx][cury].whatside=curpla;
-
- drawmap(curx,cury);
- --moves;
- }
- }
- return(0);
- }
-
- // FLYTO FOR FLYING MOVES _-_-__--___---____----_____-----______------_______
- flyto()
- {
- signed int i,x,y; // needed for random placing of flyers that kill real living enemies
- unsigned char newx=curx,newy=cury,dist;
- m.bitmapoff();m.bitmapon(5,pcol[curpla]);
- cursor=5;
-
- s.modecho(2);
- do{
- select(&newx,&newy,1);
- setcolor(0x00);line(7*32,7*32,8*32,8*32);line(8*32,7*32,7*32,8*32);//norange();
- lowbip(4);
- }
- while((dist=range(newx,newy,curx,cury))>moves);
- moves-=dist;
- //drawmap(curx,cury);//curx=tgx,cury=tgy;
-
-
-
- if(sq[newx][newy].land==10)//if tries to enter ball
- {
-
- if((!curmon)&&(sq[newx][newy].whose==curpla))
- {
- moves=0;
- sq[curx][cury].whatside=0xff;
- sq[newx][newy].whatside=curpla; //if wiz & his ball enter it
- sq[newx][newy].whatmonster=curmon;
- mon[curpla][curmon].x=newx;
- mon[curpla][curmon].y=newy;
- cury=newy;curx=newx;
- drawmap(newx,newy);
-
- return(0);
- } // if not, do nowt.
- else
- {
- if(sq[newx][newy].whose==curpla)return(0); //if your own ball no nowt
- if(sq[newx][newy].whatside==0xff)return(0);//if enemy ball but no monster inside it
- //otherwise fight thing will be used later on in this fnctn... i hope
- }
- }
-
- //okay, these 2 lines fly the monster out. It is flown back if
- //necessary elsewhere...
- drawtile(newx,newy,newx,newy);//clears target square, which is now center of screen
- drawjustland(curx,cury,newx,newy); //removes pic of flyer from start square
- spritepath((curx-newx+7)*32,(cury-newy+7)*32,32*7,32*7,tile[mon[curpla][curmon].graphic]);
- //moves flyer to taget square... it may be sent back.
-
- if((sq[newx][newy].land==1)&&sq[newx][newy].whose!=curpla)
- { //if enemy tree.
- if(decide(mon[curpla][curmon].attack,1))
- {
- s.trecho(mon[curpla][curmon],1);risingbip(3); // kill tree msg
- sq[newx][newy].land=3;sq[newx][newy].whose=4;moves=0;
- if(sq[newx][newy].whatside==0xff) //if no monster there
- {
- //drawjustland(curx,cury,newx,newy);
- //spritepath((curx-newx+7)*32,(cury-newy+7)*32,32*7,32*7,tile[mon[curpla][curmon].graphic]); //move
- sq[curx][cury].whatside=0xff;
- sq[newx][newy].whatside=curpla;
- sq[newx][newy].whatmonster=curmon;
- mon[curpla][curmon].x=newx;
- mon[curpla][curmon].y=newy;
-
- drawmap(newx,newy);
- }
- else
- { //fly back if tree destroyed but monster still sitting on stump
- drawjustland(newx,newy,newx,newy);
- spritepath(32*7,32*7,(curx-newx+7)*32,(cury-newy+7)*32,tile[mon[curpla][curmon].graphic]);
- drawtile(curx,cury,newx,newy);
- }
-
- return(0);
- }
- else
- { //failed attack on tree. no move after failed attacks
- //fly back again
- s.trecho(mon[curpla][curmon],0);moves=0;lowbip(2);
-
- drawjustland(newx,newy,newx,newy);
- spritepath(32*7,32*7,(curx-newx+7)*32,(cury-newy+7)*32,tile[mon[curpla][curmon].graphic]);
- drawtile(curx,cury,newx,newy);
-
-
- }
-
- return(0); // no point checking for move/fight if there was a tree
- }
- if(sq[newx][newy].land==5)
- { //if mirkwood
- if(decide(mon[curpla][curmon].attack,2))
- {
- s.trecho(mon[curpla][curmon],1);
- sq[newx][newy].land=0;moves=0;risingbip(3);//kill mwood
- //drawjustland(curx,cury,newx,newy);
- //spritepath((curx-newx+7)*32,(cury-newy+7)*32,32*7,32*7,tile[mon[curpla][curmon].graphic]);
- sq[curx][cury].whatside=0xff;
- sq[newx][newy].whatside=curpla; //if tree killed, move to stump
- sq[newx][newy].whatmonster=curmon;
- mon[curpla][curmon].x=newx;
- mon[curpla][curmon].y=newy; //again, move if tree died.
- cury=newy;curx=newx;
- drawmap(newx,newy);
- return(0);
- }
- else
- {
- //fly back if tree still there
- s.trecho(mon[curpla][curmon],0);moves=0;lowbip(2);
-
- drawjustland(newx,newy,newx,newy);
- spritepath(32*7,32*7,(curx-newx+7)*32,(cury-newy+7)*32,tile[mon[curpla][curmon].graphic]);
- drawtile(curx,cury,newx,newy);
-
- }
- return(0);
- }
- if((sq[newx][newy].whatside!=0xff)&&(sq[newx][newy].whatside!=curpla))
- { //if owned by enemy
- curx=newx;cury=newy;
- mon[sq[newx][newy].whatside][sq[newx][newy].whatmonster].status=fight(mon[curpla][curmon],mon[sq[newx][newy].whatside][sq[newx][newy].whatmonster]);
- curx=mon[curpla][curmon].x;cury=mon[curpla][curmon].y;
- if(mon[sq[newx][newy].whatside][sq[newx][newy].whatmonster].status==0)
- {
- sq[curx][cury].whatside=0xff;
- sq[newx][newy].whatside=curpla;
- sq[newx][newy].whatmonster=curmon;
- mon[curpla][curmon].x=newx;
- mon[curpla][curmon].y=newy;
-
- drawmap(newx,newy);
- return(0);
- }
- //if a monster vanished in fight, adjust it's square and move flyer
- if(mon[sq[newx][newy].whatside][sq[newx][newy].whatmonster].status==0x11)
- {
- for(i=0;i<15;++i) //try 15 times to find a free square to go to
- {
- x=random(3)-1;y=random(3)-1;
-
- if(sq[newx+x][newy+y].whatside==0xff)break;
- } // if none, move the damn thing anyway. huh.
- newx+=x;newy+=y; //the flyer is thus on a different square to
- sq[curx][cury].whatside=0xff; //the one it was shown flying to.
- sq[newx][newy].whatside=curpla;
- sq[newx][newy].whatmonster=curmon;
- mon[curpla][curmon].x=newx;
- mon[curpla][curmon].y=newy;
-
- drawmap(newx,newy);
- return(0);
- }
- // yo yo again if monster survived flyer's attack
- drawtile(newx,newy,newx,newy);
- spritepath(32*7,32*7,(curx-newx+7)*32,(cury-newy+7)*32,tile[mon[curpla][curmon].graphic]);
- drawtile(curx,cury,newx,newy);
-
-
- drawmap(curx,cury); // i dunno... what spaghetti :(
-
- }
-
- else
- {
- if(sq[newx][newy].whatside!=curpla)
- { // ie if no other monster in way
- //drawjustland(curx,cury,newx,newy);
- //spritepath((curx-newx+7)*32,(cury-newy+7)*32,32*7,32*7,tile[mon[curpla][curmon].graphic]);
- mon[curpla][curmon].y=newy;
- mon[curpla][curmon].x=newx;
- sq[curx][cury].whatmonster=0;sq[curx][cury].whatside=0xff;
- cury=newy;curx=newx;
- sq[curx][cury].whatmonster=curmon;sq[curx][cury].whatside=curpla;
- drawmap(curx,cury);
-
- }
- }
- return(0);
- }
-
-
-
-
-
- // FIRING FNCTN FIRE ONLY CALLS S.SHECHO etc-----------------------------------
- // this one modifies curx and cury to be the
- //cursor position & map focus, then sets them back
- // to the monster position. Argh what spaghetti
- fire(char shots,char kind)
- {
- int fx,fy,tx,ty;
- char bonus=0;// this + 10 if defender is in a dome
- // and + 10 if defender resists this kind of shot.
- --moves;--shots;
- usemouse();
- m.wheremouse();
- m.bitmapoff();cursor=3;m.bitmapon(3,pcol[curpla]);
-
-
-
- for(;;)
- {
- while(m.wheremouse())
- {
- cycleballs();
-
-
- if(kbhit())
- {
- getch();
- if (rangesight(curx,cury,mon[curpla][curmon].x,mon[curpla][curmon].y,mon[curpla][curmon].range))
- {goto selected;}
- else
- {
- setcolor(0x00);line(7*32,7*32,8*32,8*32);line(8*32,7*32,7*32,8*32);
- lowbip(4);
- }
-
-
- }
- }
- curx=curx+(m.x/32)-7;cury=cury+(m.y/32)-7;
- drawmap(curx,cury);m.putat(240,240);
- s.recho(curx,cury);
- }
- selected:;
-
- /*if(sq[curx][cury].land==10) //no shooting at domes!
- {
- curx=mon[curpla][curmon].x;
- cury=mon[curpla][curmon].y;
- lowbip(3);
- ++moves;
- return(0);
- } */
-
- if(mon[sq[curx][cury].whatside][sq[curx][cury].whatmonster].immunities==kind)bonus+=10;
- drawmap(curx,cury);
-
- fx=(mon[curpla][curmon].x-curx+7)*32+16;
- fy=(mon[curpla][curmon].y-cury+7)*32+16;
- tx=7*32+16;
- ty=7*32+16;
-
-
- if((fx==tx)&&(fy==ty)) //if attempts to shoot itself
- {
- lowbip(4);
- setcolor(0x07);setfillstyle(1,0);
- bar(180,260,320,292);
- rectangle(180,260,320,292);
- outtextxy(190,262,"Suicide is not");
- outtextxy(190,272,"allowed here...");
- return(1);
- }
-
- if (sq[curx][cury].whatside!=0xff) //only bother if monster is hit
- {
- if (sq[curx][cury].land==1) //give msg if monster in tree
- {
- s.shecho(mon[curpla][curmon],mon[sq[curx][cury].whatside][sq[curx][cury].whatmonster],0,mon[curpla][curmon].fire);
-
- if(kind==3)
- {
- sq[curx][cury].land=3; //if fireball hits tree
- sq[curx][cury].whose=0xff;
- }
- }
- else //if no tree...
- {
- if(sq[curx][cury].land==10)bonus+=10;
-
- if (!decide(kind*2,mon[sq[curx][cury].whatside][sq[curx][cury].whatmonster].defend+bonus))
- { //if miss
- s.shecho(mon[curpla][curmon],mon[sq[curx][cury].whatside][sq[curx][cury].whatmonster],1,mon[curpla][curmon].fire);
- }
- else
- { //if hit
- s.shecho(mon[curpla][curmon],mon[sq[curx][cury].whatside][sq[curx][cury].whatmonster],2,mon[curpla][curmon].fire);
- if ((kind!=3)&&(mon[sq[curx][cury].whatside][sq[curx][cury].whatmonster].status==1))
- { //if non-fireball hits living monster
- mon[sq[curx][cury].whatside][sq[curx][cury].whatmonster].status=0x11;
- }
- else
- {
- mon[sq[curx][cury].whatside][sq[curx][cury].whatmonster].status=0;
- sq[curx][cury].whatside=0xff;
- }
- ++kills[curpla];
- }
- }//end of if no tree
-
-
- }
- else //destroy tree even if no monster.
- {
- if((kind==3)&&((sq[curx][cury].land==1)||(sq[curx][cury].land==5)))
- {
- sq[curx][cury].land=3; //if fireball hits tree
- sq[curx][cury].whose=0xff;
- }
- if((kind==3)&&(sq[curx][cury].land==6))
- {
- sq[curx][cury].land=8;
- }
- }
-
- if((kind==3)&&(!random(8))&&(sq[curx][cury].land<10))sq[curx][cury].land=8;
- //1 in 8 chance of fire with fball
-
- m.bitmapoff();
-
- showfire(fx,fy,tx,ty,kind);
-
- if(sq[curx][cury].land==10)orbattacked(curx,cury); //make dome flash if hit.
-
- m.bitmapon(0,pcol[curpla]);cursor=0;
- curx=mon[curpla][curmon].x,cury=mon[curpla][curmon].y;
- drawmap(curx,cury);
- //s.usespace();
- //getch();
-
- return (shots);
- }
-
- showfire(int fx,int fy,int tx, int ty,int kind)
- {
- int i,j,sx,sy,ssx,ssy;
-
- int ax=fx,ay=fy,bx=tx,by=ty;
- int rtempx, rtempy, i_stage, steps;
- float ftempx, ftempy;
- float x_inc, y_inc;
- float x_sep=abs(ax-bx), y_sep=abs(ay-by);
-
-
- if(kind==1) //arrow,2=ray,3=fball
- {
-
- setwritemode(XOR_PUT);
- setcolor(0x0d); //xor to white
-
- for(i=0;i<3;++i)
- {
- bx+=(random(7)-3);by+=(random(7)-3);
- x_sep=abs(ax-bx); y_sep=abs(ay-by);
-
- if(x_sep > y_sep)
- {
- x_inc = 2;
- y_inc = 2*y_sep/x_sep;
- steps=x_sep/2;
- }
- else
- {
- x_inc = 2*x_sep/y_sep;
- y_inc = 2;
- steps=y_sep/2;
- }
- if (ax > bx) x_inc = -x_inc;
- if (ay > by) y_inc = -y_inc;
- ftempx = ax;
- ftempy = ay;
- setwritemode(XOR_PUT);
- for (i_stage=0;i_stage<steps-1;i_stage++)//-1 because arrow shouldnt overwrite target
- {
- ftempx += x_inc;
- ftempy += y_inc;
-
- rtempx = ftempx;
- rtempy = ftempy;
-
- if( (ftempx - rtempx) > 0.5 ) rtempx++;
- if( (ftempy - rtempy) > 0.5 ) rtempy++;
- line(rtempx,rtempy,rtempx+(x_inc*10),rtempy+(y_inc*10));
-
-
- delay(5);
-
- line(rtempx,rtempy,rtempx+(x_inc*10),rtempy+(y_inc*10));
- }
-
- }
-
- setwritemode(0);
- return(0);
- }
- if(kind==2)
- {
-
-
- setwritemode(XOR_PUT);
- for(i=4;i<12;++i)
- {
-
- setcolor(i);
- for(j=700;j<740;++j)
- {
- if(noisy){sound(random(20)+j);delay(3);sound(random(i*4));}else{delay(5);}
- line(fx,fy,tx,ty);line(fx,fy,tx+1,ty);
- line(fx,fy,tx+2,ty);line(fx,fy,tx,ty+1);
- line(fx,fy,tx,ty+2);line(fx,fy,tx-1,ty);
- line(fx,fy,tx,ty-1);line(fx,fy,tx-2,ty);
- line(fx,fy,tx,ty-2);
-
- }
- }
- nosound();
-
- setwritemode(0);
- return(0);
- }
- if(kind==3)
- {
- setwritemode(XOR_PUT);
-
- if(x_sep > y_sep)
- {
- x_inc = 1;
- y_inc = y_sep/x_sep;
- steps=x_sep;
- }
- else
- {
- x_inc = x_sep/y_sep;
- y_inc = 1;
- steps=y_sep;
- }
- if (ax > bx) x_inc = -x_inc;
- if (ay > by) y_inc = -y_inc;
- ftempx = ax;
- ftempy = ay;
- setwritemode(XOR_PUT);
- for (i_stage=0;i_stage<steps;i_stage++)
- {
- ftempx += x_inc;
- ftempy += y_inc;
-
- rtempx = ftempx;
- rtempy = ftempy;
-
- if( (ftempx - rtempx) > 0.5 ) rtempx++;
- if( (ftempy - rtempy) > 0.5 ) rtempy++;
-
- setcolor(0x0e);
- sx=rtempx+random(15)-7;sy=rtempy+random(15)-7;
- ssx=rtempx+random(7)-3;ssy=rtempy+random(7)-3;
-
- rectangle(sx-3,sy-3,sx+3,sy+3);
- moveto(sx,sy-5);linerel(0,5);linerel(-4,-2);
- moveto(sx,sy+5);linerel(0,-5);linerel(-4,2);
- moveto(sx+4,sy+2);linerel(-4,-2);linerel(4,-2);
- setcolor(0x0c);
- rectangle(ssx-3,ssy-3,ssx+3,ssy+3);
- moveto(ssx,ssy-5);linerel(0,5);linerel(-4,-2);
- moveto(ssx,ssy+5);linerel(0,-5);linerel(-4,2);
- moveto(ssx+4,ssy+2);linerel(-4,-2);linerel(4,-2);
- delay(6);
- setcolor(0x0e);
- rectangle(sx-3,sy-3,sx+3,sy+3);
- moveto(sx,sy-5);linerel(0,5);linerel(-4,-2);
- moveto(sx,sy+5);linerel(0,-5);linerel(-4,2);
- moveto(sx+4,sy+2);linerel(-4,-2);linerel(4,-2);
- setcolor(0x0c);
- rectangle(ssx-3,ssy-3,ssx+3,ssy+3);
- moveto(ssx,ssy-5);linerel(0,5);linerel(-4,-2);
- moveto(ssx,ssy+5);linerel(0,-5);linerel(-4,2);
- moveto(ssx+4,ssy+2);linerel(-4,-2);linerel(4,-2);
-
-
-
- if(noisy){sound(random(200));sound(100-i_stage);}
-
-
- }
-
-
- setwritemode(0);
- if(noisy)sound(20);
- if(sq[curx][cury].land<10)
- foom(curx,cury);
-
-
-
- nosound();
- }
-
- }
-
- spells()
- {
-
- int num,lastnum,i,a=0,real=1;
-
- m.wheremouse(); //soak up extra clix. BAD user!!
- //drawmap(caster.x,caster.y);
- m.unsetbounds();
- m.bitmapoff();cursor=2;
- s.spells(mon[curpla][curmon]);
- setwritemode(XOR_PUT);
- setcolor(0x0b);
-
- while(m.wheremouse())
- {
- cycleballs();
-
- if(!m.right()){real=0;break;}
- num=(m.y-95)/10;
- if(num<0)num=0;
- if(num>=mon[curpla][curmon].spellnum-1)num=mon[curpla][curmon].spellnum-1;
- if(kbhit()) // get help if keypress
- {
- getch();setwritemode(0);s.spellhelp(mon[curpla][curmon].spells[num]);
- m.bitmapoff();setwritemode(XOR_PUT);
- setcolor(0x0b);
- }
- if (lastnum!=num)
- {
- rectangle(481,94+lastnum*10,639,104+lastnum*10);
- rectangle(481,94+num*10,639,104+num*10);
- }
- lastnum=num;
- }
-
- m.setbounds(curx,cury);
- setwritemode(0);
- while(kbhit())
- {
- if(getch()=='!'){closegraph();bossmsg();exit(0);}
- } //naughty user!! bad,bad!!! soak up!
- bip(mon[curpla][curmon].spells[num]);
- m.bitmapon(2,pcol[curpla]);
- //foom(10,10);getch();
- castspell(mon[curpla][curmon].spells[num],real);
- s.usespace();getch();
-
- setfillstyle(1,0);bar(482,0,639,479);
- s.logo();
- s.boxes();
- drawmap(mon[curpla][curmon].x,mon[curpla][curmon].y);
- if(mon[curpla][curmon].spells[num]!=99)mon[curpla][curmon].spells[num]=0;
- for (i=0;i<mon[curpla][curmon].spellnum;++i)
- {
- if (mon[curpla][curmon].spells[i])a=1;
- }
- if (!a)mon[curpla][curmon].spellnum=0;
- m.wheremouse();
- m.bitmapoff();m.bitmapon(0,pcol[curpla]);
- return(0);
- }
-
-
-
-
- void select(char *tgx,char *tgy,int which)
- {
- //*tgx=curx;*tgy=cury;
-
- for(;;)
- {
- while(m.wheremouse())
- {
- //m.adjustmouse(*tgx,*tgy);
- cycleballs();
-
-
- if(kbhit()){getch();
- return;}
- }
-
- *tgx=*tgx+(m.x/32)-7;*tgy=*tgy+(m.y/32)-7;
-
- drawmap(*tgx,*tgy);m.putat(240,240);
- s.recho(*tgx,*tgy);
-
- }
-
- }
-
- void getadj(char *tgx,char *tgy)
- {
- char c,done=0;
- s.usekeys();
- rectangle(6*32,6*32,9*32,9*32);
- while(!done)
- {
- c=getch();
- if (c=='8'){--*tgy;done=1;}if (c=='2'){++*tgy;done=1;}
- if (c=='4'){--*tgx;done=1;}if (c=='6'){++*tgx;done=1;}
- if (c=='7'){--*tgy;--*tgx;done=1;}if (c=='9'){--*tgy;++*tgx;done=1;}
- if (c=='1'){++*tgy;--*tgx;done=1;}if (c=='3'){++*tgy;++*tgx;done=1;}
- delay(1);
- }
-
- }
-
- void foom(int sqx,int sqy)
- {
- m.bitmapoff();
- int x=(sqx-curx+7)*32,y=(sqy-cury+7)*32,i,px,py,frame;
-
- for (frame=0;frame<8;++frame)
- {
- for (i=0;i<0x400;++i)
- {
- px=x+(i % 32);py=y+(i / 32);
- if (shroom[frame][i] != 255) putpixel(px,py,shroom[frame][i]);
- if (shroom[frame][i]==0)
- {
- m.wheremouse(); //this is 4 debugging
- }
- }
- delay(50);
- setfillstyle(1,0x02);
- bar(x,y,x+31,y+31);
- }
- bar(x,y,x+31,y+31);
- drawtile(sqx,sqy,curx,cury);
- m.bitmapon(cursor,pcol[curpla]);
- delay(100);
-
- }
-
- void boof(int sqx,int sqy)
- {
- int x=((sqx-curx+7)*32)+16,y=((sqy-cury+7)*32)+16,frame;
-
-
- for(frame=20;frame>0;--frame)
- {
- setcolor(0x0f);
- circle(x,y,frame*17);
- setcolor(0x07);
- circle(x,y,frame*17+17);
- setcolor(0x08);
- circle(x,y,frame*17+34);
- setcolor(0x00);
- circle(x,y,frame*20+51);
- }
-
- }
-
-
- void moof(int sqx,int sqy)
- {
- int x=(sqx-curx+7)*32,y=(sqy-cury+7)*32,frame;
- setcolor(0x0d);
- setwritemode(XOR_PUT);
-
- for (frame=1;frame<9;++frame)
- {
- if(noisy)sound(random(1000)+1200+frame*100);
- moveto(x+16,y-frame*7+16);
- penty(frame,30);
- }
- for (frame=8;frame>0;--frame)
- {
- if(noisy)sound(random(1000)+1200+frame*100);
- moveto(x+16,y-frame*7+16);
- penty(frame,30);
- }
- nosound();
- setwritemode(0);
- }
-
-
-
- void swarm(int xa,int ya,int xb,int yb,int num) //topleft, lowright.
- {
- int xdif=(xb-xa)*32,ydif=(yb-ya)*32;
- int px=(xa-curx+7)*32,py=(ya-cury+7)*32;
- int i,j,x,y,a,b;
- setwritemode(XOR_PUT);setcolor(0x0d);
- for(i=0;i<num;++i)
- {
- x=random(xdif)+px,y=random(ydif)+py;
- a=random(xdif)+px,b=random(ydif)+py;
- line(x,y-2,x,y+2);line(x-2,y,x+2,y);
- line(a,b-2,a,b+2);line(a-2,b,a+2,b);
- if(noisy)
- {
- sound(random(1600)+600);delay(random(15));nosound();
- }
- else
- {
- delay(20);
- }
- line(x,y-2,x,y+2);line(x-2,y,x+2,y);
- line(a,b-2,a,b+2);line(a-2,b,a+2,b);
- }
- setwritemode(0);
- for(i=0;i<xb-xa;++i)
- {
- for(j=0;j<yb-ya;++j)
- {
- drawtile(xa+i,ya+j,curx,cury);
- }
- }
-
- }
-
- void penty(int frame,int del)//frame=size moveto center and setwrietmode xor first
- {
- linerel(5*frame,14*frame);linerel(-14*frame,-9*frame);
- linerel(18*frame,0);
- linerel(-14*frame,9*frame);linerel(5*frame,-14*frame);
- if(!del)return;
- delay(del);
- linerel(5*frame,14*frame);linerel(-14*frame,-9*frame);
- linerel(18*frame,0);
- linerel(-14*frame,9*frame);linerel(5*frame,-14*frame);
- return;
- }
- void crawler(int ax,int ay,int bx,int by)
- {
- int rtempx, rtempy, i_stage, steps, i;
- float ftempx, ftempy;
- float x_inc, y_inc;
- float x_sep=abs(ax-bx), y_sep=abs(ay-by);
-
- if(x_sep > y_sep)
- {
- x_inc = 1;
- y_inc = y_sep/x_sep;
- steps=x_sep;
- }
- else
- {
- x_inc = x_sep/y_sep;
- y_inc = 1;
- steps=y_sep;
- }
- if (ax > bx) x_inc = -x_inc;
- if (ay > by) y_inc = -y_inc;
- ftempx = ax;
- ftempy = ay;
- //setwritemode(XOR_PUT);
- for (i_stage=0;i_stage<steps;i_stage++)
- {
- ftempx += x_inc;
- ftempy += y_inc;
-
- rtempx = ftempx;
- rtempy = ftempy;
-
- if( (ftempx - rtempx) > 0.5 ) rtempx++;
- if( (ftempy - rtempy) > 0.5 ) rtempy++;
-
- if(sq[rtempx][rtempy].land<10) //dont kill balls
- {
- sq[rtempx][rtempy].land=4;sq[rtempx][rtempy].whose=0xff;
- if((sq[rtempx][rtempy].whatside !=0xff)&&(sq[rtempx][rtempy].whatmonster))
- {
- mon[sq[rtempx][rtempy].whatside][sq[rtempx][rtempy].whatmonster].status=0;
- sq[rtempx][rtempy].whatside=0xff;
- }
- if(noisy)
- {
- for(i=80;i>20;--i)
- {sound(i);delay(3);}
- }
- foom(rtempx,rtempy);
- nosound();
- }
-
- }
-
- }
-
-
-
-
-
- int range(long ax,long ay,long bx,long by)//goes from targ to start
- {
- int dist;
- if((ax==bx)&&(ay==by))return(0);
- if(ax==bx)return(abs(ay-by));
- if(ay==by)return(abs(ax-bx));
- double rdist=sqrt(((ax-bx)*(ax-bx)+(ay-by)*(ay-by)));
- dist = rdist;
- if (rdist-dist>0.5)++dist;
- return(dist);
-
- }
-
- int linesight(int ax,int ay, int bx,int by)
- {
-
-
-
- int rtempx, rtempy, i_stage, steps;
-
- float ftempx, ftempy;
-
- float x_inc, y_inc;
-
- float x_sep=abs(ax-bx), y_sep=abs(ay-by);
-
- if((!x_sep)&&(!y_sep))return(1);
-
-
-
-
- if(x_sep > y_sep)
- {
- x_inc = 1;
- y_inc = y_sep/x_sep;
- steps=x_sep;
- }
-
- else
- {
- x_inc = x_sep/y_sep;
- y_inc = 1;
- steps=y_sep;
- }
-
-
-
- if (ax > bx) x_inc = -x_inc;
- if (ay > by) y_inc = -y_inc;
-
-
- ftempx = ax;
- ftempy = ay;
-
- for (i_stage=0;i_stage<steps-1;i_stage++)
- {
- ftempx += x_inc;
- ftempy += y_inc;
-
- rtempx = ftempx;
- rtempy = ftempy;
-
- if( (ftempx - rtempx) > 0.5 ) rtempx++;
- if( (ftempy - rtempy) > 0.5 ) rtempy++;
-
-
-
- if(check(rtempx,rtempy))
- return(0);
-
- }
-
-
- return(1);
- }
-
-
- check(int x,int y) //return 1 if no sight thru sq[x][y]
- {
- if((sq[x][y].land==1)||
- (sq[x][y].land==2)||
- (sq[x][y].land==5)||
- (sq[x][y].land==10))
- return(1);
-
- if(sq[x][y].whatside!=0xff) //if monster
- {
- if(mon[sq[x][y].whatside][sq[x][y].whatmonster].status==0x11)
- { //if corpse/shade/whatever it is
- if(sq[x][y].whatside==curpla)
- { //if shade loyal to you
- return(0);
- }
- }
- return(1);
- }
- return(0);
- }
-
-
- int rangesight(int ax,int ay,int bx,int by, int mrange)
- {
- int dist=range(ax,ay,bx,by);
- if((linesight(ax,ay,bx,by))&&(mrange>=dist))
- {
- return(1);
- }
- return(0);
- }
-
- decide(int attack,int defend) //true if death
- {
- attack_history[curpla][thisturn]+=(attack+5)*3;//+5 to iron values flatter
- if (!defend)return(1);
- if(!attack)return(0);
-
- attack<defend?defend*=1.5:attack*=1.5;// increase spread to make it
- // bad to attack with a 3 against a 7 etc.
- int total=attack+defend;
-
- int r=random(total)+1;
- if(r>(total/2))luck_history[curpla]+=2;
- luck_history[curpla]-=1; //add 1 for a high number, -1 for a low one
-
- if((r>defend)&&(random(3)))//give 2/3 chance of success.
- {
- return(1);
- }
- return(0);
-
- }
- void usemouse()
- {
- m.bitmapoff();
- setcolor(0x07);setfillstyle(1,0);
- bar(170,260,330,292);
- rectangle(170,260,330,292);
- outtextxy(180,262,"Use the mouse to");
- outtextxy(180,272,"highlight squares;");
- outtextxy(180,282,"Space to select.");
-
- m.bitmapon(cursor,pcol[curpla]);
- }
-
- void nospells()
- {
- setcolor(0x07);setfillstyle(1,0);
- m.bitmapoff();
- bar(180,260,340,292);
- rectangle(180,260,340,292);
- outtextxy(190,262,"No spells are");
- outtextxy(190,272,"available now.");
- outtextxy(190,282,"Press something...");
-
- mygetch();
- drawmap(curx,cury);
- //m.bitmapon(cursor,pcol[curpla]);
- }
- /*void norange()
- {
- setcolor(0x07);setfillstyle(1,0);
- bar(190,260,310,272);
- rectangle(190,260,310,272);
- outtextxy(200,262,"Too far away.");
- } */
-
- void noshots()
- {
- setcolor(0x07);setfillstyle(1,0);
-
- m.bitmapoff();
- bar(180,260,340,292);
- rectangle(180,260,340,292);
- outtextxy(190,262,"You can't fire");
- outtextxy(190,272,"just now.");
- outtextxy(190,282,"Press something...");
-
- mygetch();
- drawmap(curx,cury);
- //m.bitmapon(cursor,pcol[curpla]);
- }
-
- int adjust(char *newx,char *newy) //there is no reason at all to have
- { //passed these by address... ho hum.
- if((*newx>=width)
- ||(*newx<0)
- ||(*newy>=height)
- ||(*newy<0)
- )
- return(1);
- return(0);
- }
-
- void memerror() //this never happens, in fact.
- {
- int i;
- closegraph();
- for(i=0;i<24;++i)
- free(tile[i]);
- for(i=0;i<8;++i)
- {free(terrt[i]);free(shroom[i]);}
-
- printf("Not enough memory.\n");
- exit(0);
- }
- cycleballs()
- {
- static char cycle,cycle_dir;
- int i,evil=0,good=0,red,green,blue;
- for(i=0;i<players;++i)
- {
- evil=0;good=0;
- if(alignment[i]>0){good=alignment[i]/10;}else{evil=alignment[i]/-10;}
-
- red=cycle+evil-good;if(red<0)red=0;red<<2;
- green=cycle-good-evil;if(green<0)green=0;green<<2;
- blue=cycle-evil+good;if(blue<0)blue=0;blue<<2;
- //values 0-60 leftshifted by 2 should occupy uppper 6 bits like the
- //gfx regs want...
-
- setrgbpalette(247+i,red,green,blue);
- }
- if(cycle_dir)
- {
- cycle++;
- if(cycle>30)cycle_dir=0;
- }
- else
- {
- cycle--;
- if(cycle<0)cycle_dir=1;
- }
- return(cycle); // no need
- }
-
- char mygetch()
- {
- while(!kbhit())
- {
- cycleballs();
- delay(10);
- }
- return(getch());
- }
-